package com.inf8405.db;

import com.google.api.client.util.Key;
import com.module.StationFinder.Station.Geometry;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class SQLiteHelper extends SQLiteOpenHelper {

  public static final String TABLE_NAME = "table_stations";
  public static final String COLUMN_ID = "COLUMN_ID"; //0
  public static final String COLUMN_NAME = "COLUMN_NAME"; //1
  public static final String COLUMN_REFERENCE = "COLUMN_REFERENCE"; //2
  public static final String COLUMN_ICON = "COLUMN_ICON"; //3
  public static final String COLUMN_VICINITY = "COLUMN_VICINITY"; //4
  public static final String COLUMN_GEOMETRY_LAT = "COLUMN_GEOMETRY_LAT"; //5
  public static final String COLUMN_GEOMETRY_LONG = "COLUMN_GEOMETRY_LONG";  //6
  public static final String COLUMN_FORMATTED_ADDRESS = "COLUMN_FORMATTED_ADDRESS"; //7
  public static final String COLUMN_FORMATTED_PHONE_NUMBER = "COLUMN_FORMATTED_PHONE_NUMBER"; //8
  public static final String COLUMN_PRICE = "COLUMN_PRICE"; //9
  public static final String COLUMN_PRICE_DATE = "COLUMN_PRICE_DATE"; //10
 
  public static final String DATABASE_NAME = "stationsDBTEST3.db";
  public static final int DATABASE_VERSION = 1;

  // Database creation sql statement
  private static String DATABASE_CREATE = 	  
	  "create table "
      + TABLE_NAME 
      + "(" + COLUMN_ID + " text, " 
      + COLUMN_NAME + " text,"
      + COLUMN_REFERENCE + " text,"
      + COLUMN_ICON + " text,"
      + COLUMN_VICINITY + " text,"
      + COLUMN_GEOMETRY_LAT + " text,"
      + COLUMN_GEOMETRY_LONG + " text,"
      + COLUMN_FORMATTED_ADDRESS + " text,"
      + COLUMN_FORMATTED_PHONE_NUMBER + " text,"
      + COLUMN_PRICE + " text,"
      + COLUMN_PRICE_DATE + " text);";

		  //"create table test (id text, name text);"; 
  public SQLiteHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }

  @Override
  public void onCreate(SQLiteDatabase database) {
    database.execSQL(DATABASE_CREATE);
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    Log.w(SQLiteHelper.class.getName(),
        "Upgrading database from version " + oldVersion + " to "
            + newVersion + ", which will destroy all old data");
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
    onCreate(db);
  }

}
